<!-- 统一身份验证平台登录回调页面 -->
<template>
  <div style="color: #fff">正在登录中...</div>
</template>

<script>
import { ajaxPost } from 'global/axios'
import { handleLogin } from './common.js'
import storage from 'good-storage'
export default {
  data () {
    return {
      url: '/sys/userinfo/codelogin'
    }
  },
  created () {
    this.login()
  },
  methods: {
    login () {
      // 没有Code的情况
      if (!this.$route.query.code) {
        this.$Notice.warning({
          desc: '登录失败'
        });
        return
      }
      let params = {
        data: {
          code: this.$route.query.code
        },
        url: this.url,
        token: storage.session.get('token'),
        success: res => {
          if (res.data.code === '0000') {
            this.$Message.info({
              content: res.data.message,
              duration: 1,
              onClose: () => {
                handleLogin({ that: this, res, isOtherLoginType: true })
              },
            });
          } else {
            this.$Notice.warning({
              desc: res.data.message
            });
          }
        },
      };
      ajaxPost(params);
    }
  }
}
</script>

<style  lang='scss' scoped>
</style>
